package algorithm.tree.binarytree.postorder;

import algorithm.tree.binarytree.base.TreeNode;

import java.util.function.Consumer;

public class PostorderRecursion {
    public static void traverse(TreeNode node, Consumer<TreeNode> onVisit) {
        if (node != null) {
            traverse(node.getLeft(), onVisit);
            traverse(node.getRight(), onVisit);
            onVisit.accept(node);
        }
    }
}
